home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / Cosmos.dxr / Internal_4_puzzle pieces.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  2.7 KB  |  108 lines

  1. property spriteNum, piece, action, myOgLoc, myLoc, myOgRot, oj
  2. global randomPieceLocation, rotationList, equal, completePuzzle, pootimer, points, win
  3.  
  4. on beginSprite me
  5.   piece = sprite(spriteNum)
  6.   myOgLoc = piece.loc
  7.   piece.loc = randomPieceLocation[random(randomPieceLocation.count)]
  8.   myLoc = piece.loc
  9.   randomPieceLocation.deleteOne(piece.loc)
  10.   rotlist = [90, 180, 270]
  11.   piece.rotation = piece.rotation - rotlist[random(rotlist.count)]
  12. end
  13.  
  14. on mouseEnter me
  15.   piece.locZ = spriteNum + 1000
  16. end
  17.  
  18. on mouseLeave me
  19.   piece.locZ = spriteNum
  20. end
  21.  
  22. on mouseDown me
  23.   action = timeout("LLK").new(200, #dowhat, me)
  24. end
  25.  
  26. on dowhat me
  27.   action.forget()
  28.   if the mouseDown then
  29.     puppetSound(4, member("pick up piece"))
  30.     action = timeout("LLK").new(5, #moveme, me)
  31.     oj = timeout("hffgh").new(1, #checkthis, me)
  32.   else
  33.     puppetSound(4, member("rotate"))
  34.     piece.rotation = piece.rotation + 90
  35.     if (piece.rotation = 360) or (piece.rotation = -360) then
  36.       piece.rotation = 0
  37.     end if
  38.   end if
  39. end
  40.  
  41. on moveme me
  42.   if the mouseDown then
  43.     piece.locZ = spriteNum + 1000
  44.     piece.loc = the mouseLoc
  45.   else
  46.     if the mouseUp then
  47.       action.forget()
  48.       if (the mouseH < 115) or (the mouseH > 462) or ((the mouseV < 89) or (the mouseV > 353)) then
  49.         newELoc = point(the mouseH, the mouseV)
  50.         if (newELoc[1] > 0) and (newELoc[1] < 580) and (newELoc[2] > 0) and (newELoc[2] < 440) then
  51.           piece.loc = newELoc
  52.           myLoc = piece.loc
  53.         else
  54.           piece.loc = myLoc
  55.           piece.locZ = spriteNum
  56.         end if
  57.       else
  58.         piece.loc = myLoc
  59.         piece.locZ = spriteNum
  60.       end if
  61.     end if
  62.   end if
  63. end
  64.  
  65. on checkthis me
  66.   if the mouseDown then
  67.     if (the mouseLoc > (myOgLoc - point(10, 10))) and (the mouseLoc < (myOgLoc + point(10, 10))) then
  68.       if piece.rotation = 360 then
  69.         piece.rotation = myOgRot
  70.       end if
  71.       if piece.rotation = myOgRot then
  72.         equal = 1
  73.       else
  74.         equal = 0
  75.       end if
  76.     else
  77.       equal = 0
  78.     end if
  79.   else
  80.     if the mouseUp then
  81.       oj.forget()
  82.     end if
  83.   end if
  84. end
  85.  
  86. on mouseUp me
  87.   puppetSound(4, member("drop piece"))
  88.   if equal then
  89.     action.forget()
  90.     piece.locZ = spriteNum
  91.     piece.loc = myOgLoc
  92.     piece.scriptInstanceList.deleteAll()
  93.     equal = 0
  94.     points = points + 25
  95.     do("completePuzzle" & chars(piece.member.name, 1, 3) & ".add(piece.member.name)")
  96.     if (completePuzzle[1].count + completePuzzle[2].count + completePuzzle[3].count + completePuzzle[4].count + completePuzzle[5].count + completePuzzle[6].count) = (6 * 8) then
  97.       win = "yes"
  98.       pootimer = timeout("rwer").new(150, #gotoit, me)
  99.     end if
  100.   else
  101.   end if
  102. end
  103.  
  104. on gotoit me
  105.   pootimer.forget()
  106.   go("gameover")
  107. end
  108.